package quertz.test;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.ScheduleBuilder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

import com.obor.quartz.job.biz.HelloJob;

/**
* 
* @Company OBOR
* @Author 周楠
* @Description
* 2019年4月2日
*
*/
public class Run {
	
	public static void main(String[] args) throws SchedulerException {
		
		SchedulerFactory schedFact = new StdSchedulerFactory(); 
		Scheduler sched = schedFact.getScheduler(); 
		sched.start(); 
		// define the job and tie it to our HelloJob class 
		JobDetail job = JobBuilder.newJob(HelloJob.class) 
		  .withIdentity("myJob", "group1").build(); 
		
		// Trigger the job to run now, and then every 40 seconds 
		Trigger trigger =TriggerBuilder.newTrigger() 
		  .withIdentity("myTrigger", "group1").startNow() 
		  .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(30).withRepeatCount(20)).build(); 
		// Tell quartz to schedule the job using our trigger 
		
		sched.scheduleJob(job, trigger);
		
	}

}
